//
//  LZUserInfoPresenter.m
//  laziz_Merchant
//
//  Created by ZhaoDongBo on 2016/12/21.
//  Copyright © 2016年 XBN. All rights reserved.
//

#import "LZUserInfoPresenter.h"
#import "NetworkServiceManager.h"
#import "NSString+Additions.h"
#import "MJExtension.h"

#import "GVUserDefaults+LZProperties.h"
#import "LZUserModel.h"

extern NSString *merchant;

static NSString *const kUserValidateCodeUrl             = @"/user/validateCode";    // 通过手机号码获取验证码
static NSString *const kUserLoginUrl                    = @"/user/login";           // 用户登陆接口 分为用户名密码登录和手机号验证码登录两种方式
static NSString *const kUserRegisterUrl                 = @"/user/register";        // 手机号码注册商户

static NSString *const kUserModifyPasswordUrl           = @"/user/modifyPassword";          // 用户个人中心修改密码
static NSString *const kUserChangeCellPhoneUrl          = @"/user/changeCellPhone";         // 修改用户手机号码
static NSString *const kUserResetPasswordUrl            = @"/user/resetPassword";           // 通过手机号验证码找回密码
static NSString *const kUserValidateCellPhoneUrl        = @"/user/validateUserCellPhone";   // 验证原手机号是否是当前登陆的手机号码
static NSString *const kUserSetPasswordUrl              = @"/user/setPassword";             //快捷登陆用户设置密码

static NSString *const kUserGetServiceTelUrl            = @"/merchant/getServiceTel";       // 获取平台客服电话
static NSString *const kUserGetMerchantInfoUrl          = @"/merchant/info";                // 商户信息详情
static NSString *const kUserModifySellerPhotoUrl        = @"/merchant/modifySellerPhoto";   // 修改商户头像信息
static NSString *const kUserModifyMerchantInfoUrl       = @"/merchant/modifyMerchantInfo";  // 获取商家团购商品信息列表
static NSString *const kUserGetlistMerchantHeadPhotoUrl = @"/merchant/listMerchantHeadPhoto"; //商户头图列表

static NSString *const kUserGetGrouponListUrl           = @"/groupon/list";                 // 获取商家团购商品信息列表
static NSString *const kLoginForEmailURL = @"/user/loginByEmail"; //邮箱登陆
static NSString *const kAreaCodeURL = @"/merchantBasisCountryCode/list"; //区号选择
static NSString *const kEmailVerifiCodeURL = @"/user/sendMail"; //邮箱获取验证码
static NSString *const kRegisterEmailURL = @"/user/emailRegister"; //邮箱注册
static NSString *const kResetPSByEmailURL = @"/user/resetEmailPassword"; //通过邮箱重置密码
static NSString *const kChangeEmailURL = @"/user/changeEmail"; //修改邮箱
static NSString *const kLinkPhoneOrEmailURL = @"/user/bundle"; //绑定手机或者邮箱
static NSString *const kCheckPhoneHaveBeenRegistr = @"/user/validateCellPhone"; //注册时先验证手机是否注册过
static NSString *const kAddGroupObjectURL = @"/merchant/addSellerGropon"; //发布优惠时添加团购菜品


@implementation LZUserInfoPresenter

#pragma mark - 根据类型，获取验证码
- (void)userGetVerificationPhoneNum:(NSString *)phoneNum
                       andonSuccess:(PresenterCommonSuccess)success
                             onFail:(PresenterCommonFail)fail {
    
    NSString *urlStr = COMBINATION(merchant,kUserValidateCodeUrl);
    
    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    [params setObject:phoneNum      forKey:@"cellPhone"];
    if ([[LZLanguageManager shareInstance] getLanguageType] == LanguageType_Ar) {
        [params setObject:[NSString stringWithFormat:@"2"] forKey:@"languageType"];
    } else {
        [params setObject:[NSString stringWithFormat:@"1"] forKey:@"languageType"];
    }
    
    DLog(@"%@", urlStr);
    DLog(@"%@", params);
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:params success:^(NSURLSessionDataTask *task, id resultData) {
        
        DLog(@"%@", resultData);
        
        if ([LZBasePresenter isRequestStatusCodeCorrect:resultData fail:fail]) {
            SAFE_BLOCK_INVOKE(success, resultData);
        }
        
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
        DLog(@"%@", error);
        
        SAFE_BLOCK_INVOKE(fail, error.localizedDescription);
    }];
}

#pragma mark - 邮箱登录
- (void)emailLoginWithEmail:(NSString *)email Password:(NSString *)password Success:(PresenterCommonSuccess)successBlock Failure:(PresenterCommonFail)failureBlock
{
    NSString *str  = COMBINATION(merchant,kLoginForEmailURL);
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setObject:email forKey:@"email"];
    [dic setObject:password forKey:@"password"];
    
    [[NetworkServiceManager manager] executePostTask:str parameters:dic success:^(NSURLSessionDataTask *task, id resultData) {
        if ([LZBasePresenter isRequestStatusCode:resultData fail:failureBlock]) {
            if (successBlock) {
                successBlock(resultData);
            }
        }
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
       
        if (failureBlock) {
            failureBlock(error.description);
        }
    }];
}

#pragma mark - 区号获取
- (void)getAreaCodeSuccess:(void (^)(NSArray *))successBlock Failure:(PresenterCommonFail)failureBlock
{
    NSString *urlStr = COMBINATION(merchant,kAreaCodeURL);
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:nil success:^(NSURLSessionDataTask *task, id resultData) {
        if ([LZBasePresenter isRequestStatusCode:resultData fail:failureBlock]) {
            NSArray *resultArr = resultData[@"data"];
            if (successBlock) {
                successBlock(resultArr);
            }
        }
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        if (failureBlock) {
            failureBlock(error.description);
        }
    }];
}

#pragma mark - 邮箱获取验证码
- (void)getVerificaitonCodeForEmail:(NSString *)email Success:(void (^)(NSString *))successBlock Failure:(PresenterCommonFail)failureBlock
{
    NSString *urlStr = COMBINATION(merchant,kEmailVerifiCodeURL);
    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    [params setObject:email      forKey:@"email"];
    if ([[LZLanguageManager shareInstance] getLanguageType] == LanguageType_Ar) {
        [params setObject:[NSString stringWithFormat:@"2"] forKey:@"languageType"];
    } else {
        [params setObject:[NSString stringWithFormat:@"1"] forKey:@"languageType"];
    }
    
    DLog(@"%@", urlStr);
    DLog(@"%@", params);
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:params success:^(NSURLSessionDataTask *task, id resultData) {
        
        DLog(@"%@", resultData);
        
        if ([LZBasePresenter isRequestStatusCodeCorrect:resultData fail:failureBlock]) {
            NSString *str = resultData[@"data"];
            if (successBlock) {
                successBlock(str);
            }
        }
        
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
        DLog(@"%@", error);
        
        if (failureBlock) {
            failureBlock(error.description);
        }
    }];
}

#pragma mark - 邮箱注册
- (void)registerForEmailWithEmail:(NSString *)email Password:(NSString *)passwordStr Success:(PresenterCommonSuccess)successBlock Failure:(PresenterCommonFail)failureBlock
{
    NSString *urlStr = COMBINATION(merchant,kRegisterEmailURL);
    NSMutableDictionary *dic = @{}.mutableCopy;
    [dic setObject:email forKey:@"email"];
    [dic setObject:passwordStr forKey:@"password"];
    
    [[NetworkServiceManager manager]executePostTask:urlStr parameters:dic success:^(NSURLSessionDataTask *task, id resultData) {
        if ([LZBasePresenter isRequestStatusCode:resultData fail:failureBlock]) {
            if (successBlock) {
                successBlock(resultData);
            }
        }
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        if (failureBlock) {
            failureBlock(error.description);
        }
    }];
}

#pragma mark - 通过邮箱重置密码
- (void)userResetPasswordForEmail:(NSString *)email Password:(NSString *)password Success:(PresenterCommonSuccess)successBlock Failure:(PresenterCommonFail)failureBlock
{
    NSString *urlStr = COMBINATION(merchant, kResetPSByEmailURL);
    
    NSMutableDictionary *dic = @{}.mutableCopy;
    [dic setObject:email forKey:@"email"];
    [dic setObject:password forKey:@"password"];
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:dic success:^(NSURLSessionDataTask *task, id resultData) {
        if ([LZBasePresenter isRequestStatusCode:resultData fail:failureBlock]) {
            if (successBlock) {
                successBlock(resultData);
            }
        }
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        if (failureBlock) {
            failureBlock(error.description);
        }
    }];
}

#pragma mark - 邮箱绑定
- (void)bindEmailWithEmail:(NSString *)email Success:(PresenterCommonSuccess)successBlock Failure:(PresenterCommonFail)failure
{
    NSString *urlStr = COMBINATION(merchant,kLinkPhoneOrEmailURL);
    
    NSMutableDictionary *dic = @{}.mutableCopy;
    [dic setObject:email forKey:@"email"];
    [dic setObject:[LZUserModel Instance].userToken forKey:@"token"];
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:dic success:^(NSURLSessionDataTask *task, id resultData) {
        if ([LZBasePresenter isRequestStatusCode:resultData fail:failure]) {
            if (successBlock) {
                successBlock(resultData);
            }
        }
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error.description);
        }
    }];
}

#pragma  mark - 邮箱修改
- (void)changeEmailWithOldEmail:(NSString *)oldEmail NewEmail:(NSString *)newEmail Success:(PresenterCommonSuccess)successBlock Failure:(PresenterCommonFail)failure
{
    NSString *urlStr = COMBINATION(merchant,kChangeEmailURL);
    
    NSMutableDictionary *dic = @{}.mutableCopy;
    [dic setObject:oldEmail forKey:@"email"];
    [dic setObject:newEmail forKey:@"newEmail"];
    [dic setObject:[LZUserModel Instance].userToken forKey:@"token"];
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:dic success:^(NSURLSessionDataTask *task, id resultData) {
        if ([LZBasePresenter isRequestStatusCode:resultData fail:failure]) {
            if (successBlock) {
                successBlock(resultData);
            }
        }
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error.description);
        }
    }];
}

#pragma mark - 手机绑定
- (void)bindPhoneWithPhone:(NSString *)phone Valicode:(NSString *)valicode Success:(PresenterCommonSuccess)successBlock Failure:(PresenterCommonFail)failure
{
    NSString *urlStr = COMBINATION(merchant,kLinkPhoneOrEmailURL);
    
    NSMutableDictionary *dic = @{}.mutableCopy;
    [dic setObject:phone forKey:@"cellphone"];
    [dic setObject:valicode forKey:@"valicode"];
    [dic setObject:[LZUserModel Instance].userToken forKey:@"token"];
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:dic success:^(NSURLSessionDataTask *task, id resultData) {
        if ([LZBasePresenter isRequestStatusCode:resultData fail:failure]) {
            if (successBlock) {
                successBlock(resultData);
            }
        }
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error.description);
        }
    }];
}

#pragma mark - 注册时先验证手机是否注册过
- (void)checkThePhoneHaveBeenRegister:(NSString *)phoneNum Success:(PresenterCommonSuccess)successBlock Failure:(PresenterCommonFail)failure
{
    NSString *urlStr = COMBINATION(merchant,kCheckPhoneHaveBeenRegistr);
    
    NSMutableDictionary *dic = @{}.mutableCopy;
    [dic setObject:phoneNum forKey:@"cellPhone"];
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:dic success:^(NSURLSessionDataTask *task, id resultData) {
        if ([LZBasePresenter isRequestStatusCode:resultData fail:failure]) {
            if (successBlock) {
                successBlock(resultData);
            }
        }
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error.description);
        }
    }];
}

#pragma mark - 添加团购菜品.单独的接口
- (void)addGroupOrderObjectWithName:(NSString *)objectName Price:(NSString *)objectPrice Success:(PresenterCommonSuccess)successBlock Failure:(PresenterCommonFail)failure
{
    NSString *urlStr = COMBINATION(merchant,kAddGroupObjectURL);
    
    NSMutableDictionary *dic = @{}.mutableCopy;
    [dic setObject:objectName forKey:@"foodName"];
    [dic setObject:objectPrice forKey:@"foodPrice"];
    [dic setObject:[LZUserModel Instance].userToken forKey:@"token"];
    [dic setObject:[LZUserModel Instance].sellerId forKey:@"sellerId"];
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:dic success:^(NSURLSessionDataTask *task, id resultData) {
        if ([LZBasePresenter isRequestStatusCode:resultData fail:failure]) {
            if (successBlock) {
                successBlock(resultData);
            }
        }
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error.description);
        }
    }];

}

#pragma mark - 快捷 手机密码 登录
- (void)userLoginCellPhone:(NSString *)phoneNum
   andPasswordOrVerifiCode:(NSString *)passwordOrVerifiCode
              andLoginType:(NSInteger)loginType
              andonSuccess:(PresenterCommonSuccess)success
                    onFail:(PresenterCommonFail)fail {
    
    NSString *urlStr = COMBINATION(merchant,kUserLoginUrl);
    
    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    
    if (loginType == 1) {
        [params setObject:phoneNum                  forKey:@"cellPhone"];
        [params setObject:passwordOrVerifiCode      forKey:@"validateCode"];
    } else {
        [params setObject:phoneNum                  forKey:@"userName"];
        [params setObject:passwordOrVerifiCode      forKey:@"password"];
    }
    
    [params setObject:[NSString stringWithFormat:@"%ld", (long)loginType] forKey:@"loginType"];
    
    DLog(@"%@", urlStr);
    DLog(@"%@", params);
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:params success:^(NSURLSessionDataTask *task, id resultData) {
        
        DLog(@"%@", resultData);
        
        if ([LZBasePresenter isRequestStatusCode:resultData fail:fail]) {
            SAFE_BLOCK_INVOKE(success, resultData);
        }
        
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
        DLog(@"%@", error);
        
        SAFE_BLOCK_INVOKE(fail, error.localizedDescription);
    }];
}

#pragma mark - 注册
- (void)userRegisterCellPhone:(NSString *)phoneNum
                  andPassword:(NSString *)password
          andVerificationCode:(NSString *)verifiCode
                 andonSuccess:(PresenterCommonSuccess)success
                       onFail:(PresenterCommonFail)fail {
    NSString *urlStr = COMBINATION(merchant,kUserRegisterUrl);
    
    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    [params setObject:phoneNum      forKey:@"cellPhone"];
    [params setObject:password      forKey:@"password"];
    [params setObject:verifiCode    forKey:@"validateCode"];
    
    DLog(@"%@", urlStr);
    DLog(@"%@", params);
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:params success:^(NSURLSessionDataTask *task, id resultData) {
        
        if ([LZBasePresenter isRequestStatusCodeCorrect:resultData fail:fail]) {
            SAFE_BLOCK_INVOKE(success, resultData);
        }
        
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
        SAFE_BLOCK_INVOKE(fail, error.localizedDescription);
    }];
}

#pragma mark - 修改头像
- (void)userChangeHeadImageFilePath:(NSString *)filePath
                       andonSuccess:(PresenterCommonSuccess)success
                             onFail:(PresenterCommonFail)fail {
    
    NSString *urlStr = COMBINATION(merchant,kUserModifySellerPhotoUrl);
    
    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    [params setObject:[LZUserModel Instance].userToken  forKey:@"token"];
    [params setObject:[LZUserModel Instance].sellerId   forKey:@"id"];
    [params setObject:filePath                          forKey:@"sellerPhoto"];
    
    DLog(@"%@", urlStr);
    DLog(@"%@", params);
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:params success:^(NSURLSessionDataTask *task, id resultData) {
        
        DLog(@"%@", resultData);
        
        if ([LZBasePresenter isRequestStatusCodeCorrect:resultData fail:fail]) {
            SAFE_BLOCK_INVOKE(success, resultData);
        }
        
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
        DLog(@"%@", error);
        
        SAFE_BLOCK_INVOKE(fail, error.localizedDescription);
    }];
}

#pragma mark - 用户个人中心修改密码
- (void)userChangePassword:(NSString *)oldPassword
            andNewPassword:(NSString *)newPassword
              andonSuccess:(PresenterCommonSuccess)success
                    onFail:(PresenterCommonFail)fail {
    
    NSString *urlStr = COMBINATION(merchant,kUserModifyPasswordUrl);
    
    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    [params setObject:[LZUserModel Instance].userToken forKey:@"token"];
    [params setObject:oldPassword forKey:@"password"];
    [params setObject:newPassword forKey:@"newPassword"];
    
    DLog(@"%@", urlStr);
    DLog(@"%@", params);
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:params success:^(NSURLSessionDataTask *task, id resultData) {
        
        DLog(@"%@", resultData);
        
        if ([LZBasePresenter isRequestStatusCodeCorrect:resultData fail:fail]) {
            SAFE_BLOCK_INVOKE(success, resultData);
        }
        
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
        DLog(@"%@", error);
        
        SAFE_BLOCK_INVOKE(fail, error.localizedDescription);
    }];
}

#pragma mark - 修改用户手机号码
- (void)userChangeOldMoblieNum:(NSString *)oldMoblieNum
              andOldVerifiCode:(NSString *)oldVerifiCode
               andNewMoblieNum:(NSString *)newMoblieNum
              andNewVerifiCode:(NSString *)newVerifiCode
                  andonSuccess:(PresenterCommonSuccess)success
                        onFail:(PresenterCommonFail)fail {
    
    NSString *urlStr = COMBINATION(merchant,kUserChangeCellPhoneUrl);
    
    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    [params setObject:oldMoblieNum  forKey:@"cellPhone"];
    [params setObject:oldVerifiCode forKey:@"validateCode"];
    [params setObject:newMoblieNum  forKey:@"newPhone"];
    [params setObject:newVerifiCode forKey:@"newValidateCode"];
    
    DLog(@"%@", urlStr);
    DLog(@"%@", params);
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:params success:^(NSURLSessionDataTask *task, id resultData) {
        
        DLog(@"%@", resultData);
        
        if ([LZBasePresenter isRequestStatusCodeCorrect:resultData fail:fail]) {
            SAFE_BLOCK_INVOKE(success, resultData);
        }
        
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
        DLog(@"%@", error);
        
        SAFE_BLOCK_INVOKE(fail, error.localizedDescription);
    }];
}

#pragma mark - 初始化密码
- (void)userInitPasswordWithPassword:(NSString *)password
                         andonSuccess:(PresenterCommonSuccess)success
                               onFail:(PresenterCommonFail)fail {
    
    NSString *urlStr = COMBINATION(merchant,kUserSetPasswordUrl);
    
    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    [params setObject:[LZUserModel Instance].userToken  forKey:@"token"];
    [params setObject:[LZUserModel Instance].userId     forKey:@"userId"];
    [params setObject:password                          forKey:@"password"];
    
    DLog(@"%@", urlStr);
    DLog(@"%@", params);
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:params success:^(NSURLSessionDataTask *task, id resultData) {
        
        DLog(@"初始化密码%@", resultData);
        
        if ([LZBasePresenter isRequestStatusCodeCorrect:resultData fail:fail]) {
            SAFE_BLOCK_INVOKE(success, resultData);
        }
        
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
        DLog(@"初始化密码%@", error);
        
        SAFE_BLOCK_INVOKE(fail, error.localizedDescription);
    }];
}

#pragma mark - 通过手机号验证码找回密码
- (void)userResetPasswordWithMoblieNum:(NSString *)moblieNum
                         andVerifiCode:(NSString *)verifiCode
                           andPassword:(NSString *)password
                          andonSuccess:(PresenterCommonSuccess)success
                                onFail:(PresenterCommonFail)fail {
    
    NSString *urlStr = COMBINATION(merchant,kUserResetPasswordUrl);
    
    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    [params setObject:moblieNum     forKey:@"cellPhone"];
    [params setObject:verifiCode    forKey:@"validateCode"];
    [params setObject:password      forKey:@"password"];
    
    DLog(@"%@", urlStr);
    DLog(@"%@", params);
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:params success:^(NSURLSessionDataTask *task, id resultData) {
        
        DLog(@"%@", resultData);
        
        if ([LZBasePresenter isRequestStatusCodeCorrect:resultData fail:fail]) {
            SAFE_BLOCK_INVOKE(success, resultData);
        }
        
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
        DLog(@"%@", error);
        
        SAFE_BLOCK_INVOKE(fail, error.localizedDescription);
    }];
}

#pragma mark - 验证原手机号是否是当前登陆的手机号码
- (void)userValidateUserPhoneWithMoblieNum:(NSString *)moblieNum
                              andonSuccess:(PresenterCommonSuccess)success
                                    onFail:(PresenterCommonFail)fail {
    
    NSString *urlStr = COMBINATION(merchant,kUserValidateCellPhoneUrl);
    
    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    [params setObject:moblieNum                         forKey:@"cellPhone"];
    [params setObject:[LZUserModel Instance].userToken  forKey:@"token"];
    
    DLog(@"%@", urlStr);
    DLog(@"%@", params);
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:params success:^(NSURLSessionDataTask *task, id resultData) {
        
        DLog(@"%@", resultData);
        
        if ([LZBasePresenter isRequestStatusCodeCorrect:resultData fail:fail]) {
            SAFE_BLOCK_INVOKE(success, resultData);
        }
        
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
        DLog(@"%@", error);
        
        SAFE_BLOCK_INVOKE(fail, error.localizedDescription);
    }];
}

#pragma mark - 获取商户信息详情
- (void)userGetMerchantInfoSuccess:(PresenterCommonSuccess)success
                            onFail:(PresenterCommonFail)fail {
    
    NSString *urlStr = COMBINATION(merchant,kUserGetMerchantInfoUrl);
    
    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    [params setObject:[LZUserModel Instance].sellerId forKey:@"id"];
    
    DLog(@"%@", urlStr);
    DLog(@"%@", params);
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:params success:^(NSURLSessionDataTask *task, id resultData) {
        
        DLog(@"%@", resultData);
        
        if ([LZBasePresenter isRequestStatusCodeCorrect:resultData fail:fail]) {
            SAFE_BLOCK_INVOKE(success, resultData);
        }
        
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
        DLog(@"%@", error);
        
        SAFE_BLOCK_INVOKE(fail, error.localizedDescription);
    }];
}

#pragma mark - 获取团购商品列表
- (void)userGetGrouponListSuccess:(PresenterCommonSuccess)success
                           onFail:(PresenterCommonFail)fail {
    
    NSString *urlStr = COMBINATION(merchant,kUserGetGrouponListUrl);
    
    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    [params setObject:[LZUserModel Instance].sellerId forKey:@"sellerId"];
    
    DLog(@"%@", urlStr);
    DLog(@"%@", params);
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:params success:^(NSURLSessionDataTask *task, id resultData) {
        
        DLog(@"%@", resultData);
        
        if ([LZBasePresenter isRequestStatusCodeCorrect:resultData fail:fail]) {
            SAFE_BLOCK_INVOKE(success, resultData);
        }
        
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
        DLog(@"%@", error);
        
        SAFE_BLOCK_INVOKE(fail, error.localizedDescription);
    }];
}

#pragma mark - 个人中心修改商户资料接口
- (void)userModifyMerchantInfoDict:(NSMutableDictionary *)params
                         onSuccess:(PresenterCommonSuccess)success
                            onFail:(PresenterCommonFail)fail {

    NSString *urlStr = COMBINATION(merchant,kUserModifyMerchantInfoUrl);
    
    DLog(@"%@", urlStr);
    DLog(@"%@", params);
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:params success:^(NSURLSessionDataTask *task, id resultData) {
        
        DLog(@"%@", resultData);
        
        if ([LZBasePresenter isRequestStatusCodeCorrect:resultData fail:fail]) {
            SAFE_BLOCK_INVOKE(success, resultData);
        }
        
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
        DLog(@"%@", error);
        
        SAFE_BLOCK_INVOKE(fail, error.localizedDescription);
    }];
}

#pragma mark - 个人中心获取平台客服电话接口
- (void)userGetServiceTelSuccess:(PresenterCommonSuccess)success
                            onFail:(PresenterCommonFail)fail {
    
    NSString *urlStr = COMBINATION(merchant,kUserGetServiceTelUrl);
    DLog(@"%@", urlStr);

    [[NetworkServiceManager manager] executePostTask:urlStr parameters:nil success:^(NSURLSessionDataTask *task, id resultData) {
        
        DLog(@"%@", resultData);
        
        if ([LZBasePresenter isRequestStatusCodeCorrect:resultData fail:fail]) {
            SAFE_BLOCK_INVOKE(success, resultData);
        }
        
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
        DLog(@"%@", error);
        
        SAFE_BLOCK_INVOKE(fail, error.localizedDescription);
    }];
}


#pragma mark - 查询商户头图
- (void)userGetlistMerchantHeadPhotoonSuccess:(PresenterCommonSuccess)success
                                       onFail:(PresenterCommonFail)fail {
    
    NSString *urlStr = COMBINATION(merchant,kUserGetlistMerchantHeadPhotoUrl);

    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    [params setObject:[LZUserModel Instance].sellerId forKey:@"sellerId"];
    
    DLog(@"%@", urlStr);
    DLog(@"%@", params);
    
    [[NetworkServiceManager manager] executePostTask:urlStr parameters:params success:^(NSURLSessionDataTask *task, id resultData) {
        
        DLog(@"%@", resultData);
        
        if ([LZBasePresenter isRequestStatusCodeCorrect:resultData fail:fail]) {
            SAFE_BLOCK_INVOKE(success, resultData);
        }
        
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
        DLog(@"%@", error);
        
        SAFE_BLOCK_INVOKE(fail, error.localizedDescription);
    }];
}
@end
